<template>
  <div class="">
    <DataManipulation
      title="添加合同类别"
      formRef="addContractsRef"
      :formList="formList"
      :form="form"
      :rules="rules"
      :buttonList="buttonList"
      @verifiedPassed="submitForm"
      style="margin: 0 20px 0 13px"
    />
  </div>
</template>

<script>
import { addContractCategory } from "@/api/contract/ContractCategory";
export default {
  data() {
    return {
      formList: [
        {
          labelList: [
            {
              label: "合同类别",
              prop: "name",
              type: "el-input",
              components: {
                placeholder: "请输入",
              },
            },
          ],
        },
      ],
      form: {
        belongingCompanyId: "",
        name: "",
        state: 0,
      },
      rules: {
        name: [
          {
            required: true,
            message: "合同类别不能为空",
            trigger: "blur",
          },
        ],
      },
      buttonList: [
        {
          text: "取消",
          methods: this.Cancel,
        },
      ],
    }; //这里存放数据
  },
  methods: {
    Cancel() {
      this.$router.go(-1);
    },
    submitForm() {
      this.form.belongingCompanyId = this.$route.query.belongingCompanyId;
      console.log(this.form);
      addContractCategory(this.form).then((res) => {
        console.log(res);
        this.$modal.msgSuccess("新增成功");
        this.Cancel();
      });
    },
  }, //方法集合
};
</script>
<style scoped></style>
